{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "formfilling deeppavlov tutorial.ipynb",
      "provenance": [],
      "collapsed_sections": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wUeGc-hrBwna"
      },
      "source": [
        "# How Do I: Use Form-Filling in Go-Bot Skill with RASA DSLs (v1)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "7qB_iCBCCHsK"
      },
      "source": [
        "Form-filling is the task of collection some slots information from user.\r\n",
        "\r\n",
        "## Form Filling In DeepPavlov Go-Bot Framework\r\n",
        "Form filling takes parts in two config files: `domain` and `stories` configs. \r\n",
        "\r\n",
        "### `Domain.yml` configuration for formfilling\r\n",
        "One should define forms in the `forms` section of `domain.yml`.\r\n",
        "Each form is an object listing the slots that have to be filled for form to succeed. See `zoo_form` as a reference. `from_entity` is the only supported format for now.\r\n",
        "\r\n",
        "```\r\n",
        "forms:\r\n",
        "  zoo_form:\r\n",
        "    animal:\r\n",
        "      - type: from_entity\r\n",
        "        entity: animal\r\n",
        "```\r\n",
        "\r\n",
        "### `Stories.md` configuration for formfilling\r\n",
        "\r\n",
        "form filling and the action that should happen when the ffiling is done are listed as two consecutive turns in `stories.md` as it is done in RASA 1.X DSL. See e.g. formfilling story below:\r\n",
        "\r\n",
        "```\r\n",
        "## formfilling dialogue\r\n",
        "* greet\r\n",
        "  - form{\"name\": \"zoo_form\"}\r\n",
        "  - utter_api_call\r\n",
        "```"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mKHBh1lcCwzx"
      },
      "source": [
        "##Minimal demo\r\n",
        "Minimal demo "
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "T9VbIavfkEnk",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "ec71da37-95ac-4541-ecbd-4956d0bdd09a"
      },
      "source": [
        "DP_MIN_DEMO_DIR = \"dp_minimal_demo_dir\"  # we will work in this folder\n",
        "import os\n",
        "\n",
        "%cd /content\n",
        "os.makedirs(DP_MIN_DEMO_DIR, exist_ok=True)"
      ],
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/content\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "SNC-jU9pED8p"
      },
      "source": [
        "### `Stories.md`"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "hm3VCqMNJAOD"
      },
      "source": [
        "STORIES_PATH = f\"{DP_MIN_DEMO_DIR}/stories.md\""
      ],
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "edx8nWiSk5RV",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "8e297007-88ee-43f5-b2af-1277f055d94e"
      },
      "source": [
        "%%writefile {STORIES_PATH}\n",
        "\n",
        "## greet dialogue\n",
        "* greet\n",
        "  - utter_greet\n",
        "\n",
        "## formfilling dialogue\n",
        "* greet\n",
        "  - form{\"name\": \"zoo_form\"}\n",
        "  - utter_api_call\n"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Writing dp_minimal_demo_dir/stories.md\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "KXQdDMrql5VE"
      },
      "source": [
        "!cp {DP_MIN_DEMO_DIR}/stories.md {DP_MIN_DEMO_DIR}/stories-trn.md\n",
        "!cp {DP_MIN_DEMO_DIR}/stories.md {DP_MIN_DEMO_DIR}/stories-tst.md \n",
        "!cp {DP_MIN_DEMO_DIR}/stories.md {DP_MIN_DEMO_DIR}/stories-val.md"
      ],
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "KXVajIbEFKbC"
      },
      "source": [
        "### `NLU.md`"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "QzuUHHdxI2mK"
      },
      "source": [
        "NLU_PATH=f\"{DP_MIN_DEMO_DIR}/nlu.md\""
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "tpXxp5Tlk-cS",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "61ecc86e-785d-4962-b6ba-75600df110f7"
      },
      "source": [
        "%%writefile {NLU_PATH}\n",
        "## intent:greet\n",
        "- Hi\n",
        "- Hey\n",
        "- Hi bot\n",
        "- Hey bot\n",
        "- Hello\n",
        "- Good morning\n",
        "- hi again\n",
        "- hi folks\n",
        "\n",
        "## intent:inform_animal\n",
        "- I'm looking for a [cat](animal)\n",
        "- I am looking for a [cat](animal)\n",
        "- I am looking for a [dog](animal)\n",
        "- I am looking for a [fox](animal)\n",
        "\n",
        "## intent:inform_time\n",
        "- [Evening](time) is fine\n",
        "- I think that this [morning](time)\n",
        "- I am looking for a cat this [morning](time)"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Writing dp_minimal_demo_dir/nlu.md\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "HhinLEavFNH9"
      },
      "source": [
        "###`Domain.yml`"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "0LGsxdsPIwh-"
      },
      "source": [
        "DOMAIN_PATH=f\"{DP_MIN_DEMO_DIR}/domain.yml\""
      ],
      "execution_count": 7,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "1k_L_-PVk-td",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "7230e7ee-5560-4624-fb1d-56fadd4a433d"
      },
      "source": [
        "%%writefile {DOMAIN_PATH}\n",
        "intents:\n",
        "  - greet\n",
        "  - inform_animal\n",
        "  - inform_time\n",
        "\n",
        "actions:\n",
        "  - utter_api_call\n",
        "\n",
        "slots:\n",
        "  time:\n",
        "    type: str\n",
        "  animal:\n",
        "    type: str\n",
        "\n",
        "responses:\n",
        "  utter_greet:\n",
        "    - text: Hi\n",
        "  utter_ask_animal:\n",
        "    - text: Could you please tell me which animal ure lookin for\n",
        "  utter_ask_time:\n",
        "    - text: What's the desired time\n",
        "  \n",
        "forms:\n",
        "    zoo_form:\n",
        "        animal:\n",
        "          - type: from_entity\n",
        "            entity: animal\n",
        "        time:\n",
        "          - type: from_entity\n",
        "            entity: time"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Writing dp_minimal_demo_dir/domain.yml\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JZ4HoB6zFbO-"
      },
      "source": [
        "### Install the deeppavlov library"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "vR-EHU-wFUE3",
        "outputId": "07698a69-dbff-4d50-937d-c243cf6db052"
      },
      "source": [
        "!pip install git+https://github.com/deepmipt/DeepPavlov.git@feature/gobot_naive_formfilling"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Collecting git+https://github.com/deepmipt/DeepPavlov.git@feature/gobot_naive_formfilling\n",
            "  Cloning https://github.com/deepmipt/DeepPavlov.git (to revision feature/gobot_naive_formfilling) to /tmp/pip-req-build-bdygyo_5\n",
            "  Running command git clone -q https://github.com/deepmipt/DeepPavlov.git /tmp/pip-req-build-bdygyo_5\n",
            "  Running command git checkout -b feature/gobot_naive_formfilling --track origin/feature/gobot_naive_formfilling\n",
            "  Switched to a new branch 'feature/gobot_naive_formfilling'\n",
            "  Branch 'feature/gobot_naive_formfilling' set up to track remote branch 'feature/gobot_naive_formfilling' from 'origin'.\n",
            "Collecting aio-pika==6.4.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/c8/07/196a4115cbef31fa0c3dabdea146f02dffe5e49998341d20dbe2278953bc/aio_pika-6.4.1-py3-none-any.whl (40kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 4.1MB/s \n",
            "\u001b[?25hCollecting Cython==0.29.14\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/df/d1/4d3f8a7a920e805488a966cc6ab55c978a712240f584445d703c08b9f405/Cython-0.29.14-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)\n",
            "\u001b[K     |████████████████████████████████| 2.1MB 7.9MB/s \n",
            "\u001b[?25hCollecting fastapi==0.47.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a3/a7/4804d7abf8a1544d079d50650af872387154ebdac5bd07d54b2e60e2b334/fastapi-0.47.1-py3-none-any.whl (43kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 5.0MB/s \n",
            "\u001b[?25hRequirement already satisfied: filelock==3.0.12 in /usr/local/lib/python3.6/dist-packages (from deeppavlov==0.13.0) (3.0.12)\n",
            "Requirement already satisfied: h5py==2.10.0 in /usr/local/lib/python3.6/dist-packages (from deeppavlov==0.13.0) (2.10.0)\n",
            "Collecting nltk==3.4.5\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/f6/1d/d925cfb4f324ede997f6d47bea4d9babba51b49e87a767c170b77005889d/nltk-3.4.5.zip (1.5MB)\n",
            "\u001b[K     |████████████████████████████████| 1.5MB 34.3MB/s \n",
            "\u001b[?25hCollecting numpy==1.18.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/92/e6/45f71bd24f4e37629e9db5fb75caab919507deae6a5a257f9e4685a5f931/numpy-1.18.0-cp36-cp36m-manylinux1_x86_64.whl (20.1MB)\n",
            "\u001b[K     |████████████████████████████████| 20.1MB 1.2MB/s \n",
            "\u001b[?25hCollecting overrides==2.7.0\n",
            "  Downloading https://files.pythonhosted.org/packages/ac/98/2430afd204c48ac0a529d439d7e22df8fa603c668d03456b5947cb59ec36/overrides-2.7.0.tar.gz\n",
            "Collecting pandas==0.25.3\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/52/3f/f6a428599e0d4497e1595030965b5ba455fd8ade6e977e3c819973c4b41d/pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)\n",
            "\u001b[K     |████████████████████████████████| 10.4MB 35.0MB/s \n",
            "\u001b[?25hCollecting prometheus-client==0.7.1\n",
            "  Downloading https://files.pythonhosted.org/packages/b3/23/41a5a24b502d35a4ad50a5bb7202a5e1d9a0364d0c12f56db3dbf7aca76d/prometheus_client-0.7.1.tar.gz\n",
            "Collecting pytz==2019.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl (510kB)\n",
            "\u001b[K     |████████████████████████████████| 512kB 42.3MB/s \n",
            "\u001b[?25hCollecting pydantic==1.3\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/99/24/e78cf017628e7eaed20cb040999b1ecc69f872da53dfd0d9aed40c0fa5f1/pydantic-1.3-cp36-cp36m-manylinux2010_x86_64.whl (7.3MB)\n",
            "\u001b[K     |████████████████████████████████| 7.3MB 27.7MB/s \n",
            "\u001b[?25hCollecting pymorphy2==0.8\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a3/33/fff9675c68b5f6c63ec8c6e6ff57827dda28a1fa5b2c2d727dffff92dd47/pymorphy2-0.8-py2.py3-none-any.whl (46kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 6.3MB/s \n",
            "\u001b[?25hCollecting pymorphy2-dicts-ru\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3a/79/bea0021eeb7eeefde22ef9e96badf174068a2dd20264b9a378f2be1cdd9e/pymorphy2_dicts_ru-2.4.417127.4579844-py2.py3-none-any.whl (8.2MB)\n",
            "\u001b[K     |████████████████████████████████| 8.2MB 37.4MB/s \n",
            "\u001b[?25hCollecting pyopenssl==19.1.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/9e/de/f8342b68fa9e981d348039954657bdf681b2ab93de27443be51865ffa310/pyOpenSSL-19.1.0-py2.py3-none-any.whl (53kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 7.7MB/s \n",
            "\u001b[?25hCollecting pytelegrambotapi==3.6.7\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/62/ab/99c606f69fcda57e35788b913dd34c9d9acb48dd26349141b3855dcf6351/pyTelegramBotAPI-3.6.7.tar.gz (65kB)\n",
            "\u001b[K     |████████████████████████████████| 71kB 8.2MB/s \n",
            "\u001b[?25hCollecting requests==2.22.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 7.7MB/s \n",
            "\u001b[?25hCollecting ruamel.yaml==0.15.100\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/e7/9f/83bb34eaf84032b0b54fcc4a6aff1858572d279d65a301c7ae875f523df5/ruamel.yaml-0.15.100-cp36-cp36m-manylinux1_x86_64.whl (656kB)\n",
            "\u001b[K     |████████████████████████████████| 665kB 48.1MB/s \n",
            "\u001b[?25hCollecting rusenttokenize==0.0.5\n",
            "  Downloading https://files.pythonhosted.org/packages/25/4c/a2f00be5def774a3df2e5387145f1cb54e324607ec4a7e23f573645946e7/rusenttokenize-0.0.5-py3-none-any.whl\n",
            "Collecting scikit-learn==0.21.2\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/85/04/49633f490f726da6e454fddc8e938bbb5bfed2001681118d3814c219b723/scikit_learn-0.21.2-cp36-cp36m-manylinux1_x86_64.whl (6.7MB)\n",
            "\u001b[K     |████████████████████████████████| 6.7MB 41.5MB/s \n",
            "\u001b[?25hRequirement already satisfied: scipy==1.4.1 in /usr/local/lib/python3.6/dist-packages (from deeppavlov==0.13.0) (1.4.1)\n",
            "Requirement already satisfied: tqdm==4.41.1 in /usr/local/lib/python3.6/dist-packages (from deeppavlov==0.13.0) (4.41.1)\n",
            "Requirement already satisfied: click==7.1.2 in /usr/local/lib/python3.6/dist-packages (from deeppavlov==0.13.0) (7.1.2)\n",
            "Collecting uvicorn==0.11.7\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a9/5f/2bc87272f189662e129ddcd4807ad3ef83128b4df3a3482335f5f9790f24/uvicorn-0.11.7-py3-none-any.whl (43kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 5.9MB/s \n",
            "\u001b[?25hCollecting sacremoses==0.0.35\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/1f/8e/ed5364a06a9ba720fddd9820155cc57300d28f5f43a6fd7b7e817177e642/sacremoses-0.0.35.tar.gz (859kB)\n",
            "\u001b[K     |████████████████████████████████| 860kB 38.2MB/s \n",
            "\u001b[?25hCollecting aiormq<4,>=3.2.0\n",
            "  Downloading https://files.pythonhosted.org/packages/0b/c4/dc5b9d50c15af2ee187974a5a0c3f20c06cce6559eea4c065d372e846b6a/aiormq-3.3.1-py3-none-any.whl\n",
            "Collecting yarl\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/da/08/52b26b44bce7b818b410aee37c5e424c9ea420c557bca97dc2adac29b151/yarl-1.6.3-cp36-cp36m-manylinux2014_x86_64.whl (293kB)\n",
            "\u001b[K     |████████████████████████████████| 296kB 44.9MB/s \n",
            "\u001b[?25hCollecting starlette<=0.12.9,>=0.12.9\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/67/95/2220fe5bf287e693a6430d8ee36c681b0157035b7249ec08f8fb36319d16/starlette-0.12.9.tar.gz (46kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 5.9MB/s \n",
            "\u001b[?25hRequirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from h5py==2.10.0->deeppavlov==0.13.0) (1.15.0)\n",
            "Requirement already satisfied: python-dateutil>=2.6.1 in /usr/local/lib/python3.6/dist-packages (from pandas==0.25.3->deeppavlov==0.13.0) (2.8.1)\n",
            "Requirement already satisfied: dataclasses>=0.6; python_version < \"3.7\" in /usr/local/lib/python3.6/dist-packages (from pydantic==1.3->deeppavlov==0.13.0) (0.8)\n",
            "Collecting pymorphy2-dicts<3.0,>=2.4\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/02/51/2465fd4f72328ab50877b54777764d928da8cb15b74e2680fc1bd8cb3173/pymorphy2_dicts-2.4.393442.3710985-py2.py3-none-any.whl (7.1MB)\n",
            "\u001b[K     |████████████████████████████████| 7.1MB 35.3MB/s \n",
            "\u001b[?25hRequirement already satisfied: docopt>=0.6 in /usr/local/lib/python3.6/dist-packages (from pymorphy2==0.8->deeppavlov==0.13.0) (0.6.2)\n",
            "Collecting dawg-python>=0.7\n",
            "  Downloading https://files.pythonhosted.org/packages/6a/84/ff1ce2071d4c650ec85745766c0047ccc3b5036f1d03559fd46bb38b5eeb/DAWG_Python-0.7.2-py2.py3-none-any.whl\n",
            "Collecting cryptography>=2.8\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/c9/de/7054df0620b5411ba45480f0261e1fb66a53f3db31b28e3aa52c026e72d9/cryptography-3.3.1-cp36-abi3-manylinux2010_x86_64.whl (2.6MB)\n",
            "\u001b[K     |████████████████████████████████| 2.6MB 38.9MB/s \n",
            "\u001b[?25hCollecting idna<2.9,>=2.5\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 6.5MB/s \n",
            "\u001b[?25hRequirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests==2.22.0->deeppavlov==0.13.0) (3.0.4)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests==2.22.0->deeppavlov==0.13.0) (2020.12.5)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests==2.22.0->deeppavlov==0.13.0) (1.24.3)\n",
            "Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.21.2->deeppavlov==0.13.0) (1.0.0)\n",
            "Collecting h11<0.10,>=0.8\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/5a/fd/3dad730b0f95e78aeeb742f96fa7bbecbdd56a58e405d3da440d5bfb90c6/h11-0.9.0-py2.py3-none-any.whl (53kB)\n",
            "\u001b[K     |████████████████████████████████| 61kB 6.3MB/s \n",
            "\u001b[?25hCollecting websockets==8.*\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/bb/d9/856af84843912e2853b1b6e898ac8b802989fcf9ecf8e8445a1da263bf3b/websockets-8.1-cp36-cp36m-manylinux2010_x86_64.whl (78kB)\n",
            "\u001b[K     |████████████████████████████████| 81kB 8.8MB/s \n",
            "\u001b[?25hCollecting httptools==0.1.*; sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\"\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/b1/a6/dc1e7e8f4049ab70d52c9690ec10652e268ab2542853033cc1d539594102/httptools-0.1.1-cp36-cp36m-manylinux1_x86_64.whl (216kB)\n",
            "\u001b[K     |████████████████████████████████| 225kB 56.0MB/s \n",
            "\u001b[?25hCollecting uvloop>=0.14.0; sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\"\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/41/48/586225bbb02d3bdca475b17e4be5ce5b3f09da2d6979f359916c1592a687/uvloop-0.14.0-cp36-cp36m-manylinux2010_x86_64.whl (3.9MB)\n",
            "\u001b[K     |████████████████████████████████| 3.9MB 41.1MB/s \n",
            "\u001b[?25hCollecting pamqp==2.3.0\n",
            "  Downloading https://files.pythonhosted.org/packages/eb/56/afa06143361e640c9159d828dadc95fc9195c52c95b4a97d136617b0166d/pamqp-2.3.0-py2.py3-none-any.whl\n",
            "Collecting multidict>=4.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/a1/35/b22524d6b9cacfb4c5eff413a069bbc17c6ea628e54da5c6c989998ced5f/multidict-5.1.0-cp36-cp36m-manylinux2014_x86_64.whl (141kB)\n",
            "\u001b[K     |████████████████████████████████| 143kB 51.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: typing-extensions>=3.7.4; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from yarl->aio-pika==6.4.1->deeppavlov==0.13.0) (3.7.4.3)\n",
            "Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.6/dist-packages (from cryptography>=2.8->pyopenssl==19.1.0->deeppavlov==0.13.0) (1.14.4)\n",
            "Requirement already satisfied: pycparser in /usr/local/lib/python3.6/dist-packages (from cffi>=1.12->cryptography>=2.8->pyopenssl==19.1.0->deeppavlov==0.13.0) (2.20)\n",
            "Building wheels for collected packages: deeppavlov, nltk, overrides, prometheus-client, pytelegrambotapi, sacremoses, starlette\n",
            "  Building wheel for deeppavlov (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for deeppavlov: filename=deeppavlov-0.13.0-cp36-none-any.whl size=988582 sha256=eee195d1dad7be868f09011c3c9daa2f88cdcb09d7d6305c50243dac50fccb83\n",
            "  Stored in directory: /tmp/pip-ephem-wheel-cache-1ak9wj3x/wheels/67/f8/dc/6293028d2bb379acd12679f1427e48e205895d9100f34cdeda\n",
            "  Building wheel for nltk (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for nltk: filename=nltk-3.4.5-cp36-none-any.whl size=1449906 sha256=d0882c043066e8f9804a1d1e404191c3c223bd145c2484a4344de6860587206a\n",
            "  Stored in directory: /root/.cache/pip/wheels/96/86/f6/68ab24c23f207c0077381a5e3904b2815136b879538a24b483\n",
            "  Building wheel for overrides (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for overrides: filename=overrides-2.7.0-cp36-none-any.whl size=5601 sha256=aad8515db2af4c71634df80c13b468f0c296671782b1c77a3f79f9d03ef0fa8a\n",
            "  Stored in directory: /root/.cache/pip/wheels/8c/7c/ef/80508418b67d87371c5b3de49e03eb22ee7c1d19affb5099f8\n",
            "  Building wheel for prometheus-client (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for prometheus-client: filename=prometheus_client-0.7.1-cp36-none-any.whl size=41402 sha256=30a05649aa3567e1e28d253312827e25afd3e2b8a77ce6afee356dc4083bbf20\n",
            "  Stored in directory: /root/.cache/pip/wheels/1c/54/34/fd47cd9b308826cc4292b54449c1899a30251ef3b506bc91ea\n",
            "  Building wheel for pytelegrambotapi (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for pytelegrambotapi: filename=pyTelegramBotAPI-3.6.7-cp36-none-any.whl size=47179 sha256=ae1d0ccee532e02727aab9fd42f87557b743a8f2a63d9abc767945beb4bb41d4\n",
            "  Stored in directory: /root/.cache/pip/wheels/23/40/18/8a34153f95ef0dc19e3954898e5a5079244b76a8afdd7d0ec5\n",
            "  Building wheel for sacremoses (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for sacremoses: filename=sacremoses-0.0.35-cp36-none-any.whl size=884000 sha256=ff0e7febbf7d070ee0b8bb8d44f317770b0d00bb7937764e89cd446a19d1e15d\n",
            "  Stored in directory: /root/.cache/pip/wheels/63/2a/db/63e2909042c634ef551d0d9ac825b2b0b32dede4a6d87ddc94\n",
            "  Building wheel for starlette (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for starlette: filename=starlette-0.12.9-cp36-none-any.whl size=57246 sha256=eadebf92ed2e8871074303694dbd4cf0e329de65ebb6d38afb208ed13410e52e\n",
            "  Stored in directory: /root/.cache/pip/wheels/1c/51/5b/3828d52e185cafad941c4291b6f70894d0794be28c70addae5\n",
            "Successfully built deeppavlov nltk overrides prometheus-client pytelegrambotapi sacremoses starlette\n",
            "\u001b[31mERROR: tensorflow 2.4.0 has requirement numpy~=1.19.2, but you'll have numpy 1.18.0 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: google-colab 1.0.0 has requirement pandas~=1.1.0; python_version >= \"3.0\", but you'll have pandas 0.25.3 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: google-colab 1.0.0 has requirement requests~=2.23.0, but you'll have requests 2.22.0 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: fbprophet 0.7.1 has requirement pandas>=1.0.4, but you'll have pandas 0.25.3 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.\u001b[0m\n",
            "\u001b[31mERROR: albumentations 0.1.12 has requirement imgaug<0.2.7,>=0.2.5, but you'll have imgaug 0.2.9 which is incompatible.\u001b[0m\n",
            "Installing collected packages: pamqp, multidict, idna, yarl, aiormq, aio-pika, Cython, pydantic, starlette, fastapi, nltk, numpy, overrides, pytz, pandas, prometheus-client, pymorphy2-dicts, dawg-python, pymorphy2, pymorphy2-dicts-ru, cryptography, pyopenssl, requests, pytelegrambotapi, ruamel.yaml, rusenttokenize, scikit-learn, h11, websockets, httptools, uvloop, uvicorn, sacremoses, deeppavlov\n",
            "  Found existing installation: idna 2.10\n",
            "    Uninstalling idna-2.10:\n",
            "      Successfully uninstalled idna-2.10\n",
            "  Found existing installation: Cython 0.29.21\n",
            "    Uninstalling Cython-0.29.21:\n",
            "      Successfully uninstalled Cython-0.29.21\n",
            "  Found existing installation: nltk 3.2.5\n",
            "    Uninstalling nltk-3.2.5:\n",
            "      Successfully uninstalled nltk-3.2.5\n",
            "  Found existing installation: numpy 1.19.4\n",
            "    Uninstalling numpy-1.19.4:\n",
            "      Successfully uninstalled numpy-1.19.4\n",
            "  Found existing installation: pytz 2018.9\n",
            "    Uninstalling pytz-2018.9:\n",
            "      Successfully uninstalled pytz-2018.9\n",
            "  Found existing installation: pandas 1.1.5\n",
            "    Uninstalling pandas-1.1.5:\n",
            "      Successfully uninstalled pandas-1.1.5\n",
            "  Found existing installation: prometheus-client 0.9.0\n",
            "    Uninstalling prometheus-client-0.9.0:\n",
            "      Successfully uninstalled prometheus-client-0.9.0\n",
            "  Found existing installation: requests 2.23.0\n",
            "    Uninstalling requests-2.23.0:\n",
            "      Successfully uninstalled requests-2.23.0\n",
            "  Found existing installation: scikit-learn 0.22.2.post1\n",
            "    Uninstalling scikit-learn-0.22.2.post1:\n",
            "      Successfully uninstalled scikit-learn-0.22.2.post1\n",
            "Successfully installed Cython-0.29.14 aio-pika-6.4.1 aiormq-3.3.1 cryptography-3.3.1 dawg-python-0.7.2 deeppavlov-0.13.0 fastapi-0.47.1 h11-0.9.0 httptools-0.1.1 idna-2.8 multidict-5.1.0 nltk-3.4.5 numpy-1.18.0 overrides-2.7.0 pamqp-2.3.0 pandas-0.25.3 prometheus-client-0.7.1 pydantic-1.3 pymorphy2-0.8 pymorphy2-dicts-2.4.393442.3710985 pymorphy2-dicts-ru-2.4.417127.4579844 pyopenssl-19.1.0 pytelegrambotapi-3.6.7 pytz-2019.1 requests-2.22.0 ruamel.yaml-0.15.100 rusenttokenize-0.0.5 sacremoses-0.0.35 scikit-learn-0.21.2 starlette-0.12.9 uvicorn-0.11.7 uvloop-0.14.0 websockets-8.1 yarl-1.6.3\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.colab-display-data+json": {
              "pip_warning": {
                "packages": [
                  "numpy",
                  "pandas",
                  "pytz"
                ]
              }
            }
          },
          "metadata": {
            "tags": []
          }
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uE65jhD9FebW"
      },
      "source": [
        "### Imports"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "J7HfN8n0FUE5"
      },
      "source": [
        "import json\n",
        "import os\n",
        "\n",
        "from deeppavlov import build_model, train_model\n",
        "from deeppavlov.core.common.file import read_json"
      ],
      "execution_count": 10,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bNAYq_kkG_bH"
      },
      "source": [
        "### Write the `slotfiller` component chainer config"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "CNu7yYKkHZal"
      },
      "source": [
        "SLOTFILL_CONFIG_PATH = f\"{DP_MIN_DEMO_DIR}/slotfill_config.json\""
      ],
      "execution_count": 11,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "b556m0LhFxTT",
        "outputId": "c9ecff81-8ce2-41dc-ba88-b4e5083dc83e"
      },
      "source": [
        "%%writefile {SLOTFILL_CONFIG_PATH}\r\n",
        "{\r\n",
        "  \"chainer\": {\r\n",
        "    \"in\": [\"x\"],\r\n",
        "    \"in_y\": [\"y\"],\r\n",
        "    \"pipe\": [\r\n",
        "      {\r\n",
        "        \"in\": [\"x\"],\r\n",
        "        \"class_name\": \"lazy_tokenizer\",\r\n",
        "        \"out\": [\"x_tokens\"]\r\n",
        "      },\r\n",
        "      {\r\n",
        "        \"in\": [\"x_tokens\"],\r\n",
        "        \"class_name\": \"str_lower\",\r\n",
        "        \"out\": [\"x_lower\"]\r\n",
        "      },\r\n",
        "      {\r\n",
        "        \"in\": [\"x_lower\"],\r\n",
        "        \"class_name\": \"slotfill_raw_rasa\",\r\n",
        "        \"save_path\": \"{DATA_PATH}\",\r\n",
        "        \"load_path\": \"{DATA_PATH}\",\r\n",
        "        \"out\": [\"slots\"]\r\n",
        "      }\r\n",
        "    ],\r\n",
        "    \"out\": [\"slots\"]\r\n",
        "  },\r\n",
        "  \"metadata\": {\r\n",
        "    \"variables\": {\r\n",
        "      \"DATA_PATH\": \"dp_minimal_demo_dir\"\r\n",
        "    }\r\n",
        "  }\r\n",
        "}"
      ],
      "execution_count": 12,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Writing dp_minimal_demo_dir/slotfill_config.json\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "LR-D004bFJFT",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "ccb4c4be-c6d7-4791-be9c-fc16e23d2d76"
      },
      "source": [
        "slotfill_config = read_json(SLOTFILL_CONFIG_PATH)\n",
        "slotfiller = build_model(slotfill_config)"
      ],
      "execution_count": 13,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "[nltk_data] Downloading package punkt to /root/nltk_data...\n",
            "[nltk_data]   Unzipping tokenizers/punkt.zip.\n",
            "[nltk_data] Downloading package stopwords to /root/nltk_data...\n",
            "[nltk_data]   Unzipping corpora/stopwords.zip.\n",
            "[nltk_data] Downloading package perluniprops to /root/nltk_data...\n",
            "[nltk_data]   Unzipping misc/perluniprops.zip.\n",
            "[nltk_data] Downloading package nonbreaking_prefixes to\n",
            "[nltk_data]     /root/nltk_data...\n",
            "[nltk_data]   Unzipping corpora/nonbreaking_prefixes.zip.\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "JzVQ0MHCqRW3",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "63c87a9c-a736-4cd2-8da9-6c2ba986b31e"
      },
      "source": [
        "slotfiller([\"Hello i'm looking for a cat\"])"
      ],
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[{'animal': 'cat'}]"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 14
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "d8C8yuoiPTLv"
      },
      "source": [
        "### Train the Go-Bot"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "lFktvlWtID3a"
      },
      "source": [
        "GOBOT_CONFIG_PATH = f\"{DP_MIN_DEMO_DIR}/gobot_config.json\""
      ],
      "execution_count": 15,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "8hQuqCgeJl0_",
        "outputId": "0ab60bd9-5518-4361-edff-91e6bcc45811"
      },
      "source": [
        "%%writefile {GOBOT_CONFIG_PATH}\r\n",
        "{\r\n",
        "  \"dataset_reader\": {\r\n",
        "    \"class_name\": \"md_yaml_dialogs_reader\",\r\n",
        "    \"data_path\": \"{DATA_PATH}\",\r\n",
        "    \"ignore_slots\": false\r\n",
        "  },\r\n",
        "  \"dataset_iterator\": {\r\n",
        "    \"class_name\": \"dialog_iterator\"\r\n",
        "  },\r\n",
        "  \"chainer\": {\r\n",
        "    \"in\": [\r\n",
        "      \"x\"\r\n",
        "    ],\r\n",
        "    \"in_y\": [\r\n",
        "      \"y\"\r\n",
        "    ],\r\n",
        "    \"out\": [\r\n",
        "      \"y_predicted\"\r\n",
        "    ],\r\n",
        "    \"pipe\": [\r\n",
        "      {\r\n",
        "        \"class_name\": \"deeppavlov.models.go_bot.wrapper:DialogComponentWrapper\",\r\n",
        "        \"component\": {\r\n",
        "          \"class_name\": \"split_tokenizer\"\r\n",
        "        },\r\n",
        "        \"in\": [\r\n",
        "          \"x\"\r\n",
        "        ],\r\n",
        "        \"out\": [\r\n",
        "          \"x_tokens\"\r\n",
        "        ]\r\n",
        "      },\r\n",
        "      {\r\n",
        "        \"id\": \"word_vocab\",\r\n",
        "        \"class_name\": \"simple_vocab\",\r\n",
        "        \"fit_on\": [\r\n",
        "          \"x_tokens\"\r\n",
        "        ],\r\n",
        "        \"save_path\": \"{MODEL_PATH}/word.dict\",\r\n",
        "        \"load_path\": \"{MODEL_PATH}/word.dict\"\r\n",
        "      },\r\n",
        "      {\r\n",
        "        \"class_name\": \"go_bot\",\r\n",
        "        \"load_path\": \"{MODEL_PATH}/model\",\r\n",
        "        \"save_path\": \"{MODEL_PATH}/model\",\r\n",
        "        \"in\": [\r\n",
        "          \"x\"\r\n",
        "        ],\r\n",
        "        \"in_y\": [\r\n",
        "          \"y\"\r\n",
        "        ],\r\n",
        "        \"out\": [\r\n",
        "          \"y_predicted\"\r\n",
        "        ],\r\n",
        "        \"main\": true,\r\n",
        "        \"debug\": false,\r\n",
        "        \"learning_rate\": 0.003,\r\n",
        "        \"learning_rate_drop_patience\": 5,\r\n",
        "        \"learning_rate_drop_div\": 10,\r\n",
        "        \"momentum\": 0.95,\r\n",
        "        \"optimizer\": \"tensorflow.train:AdamOptimizer\",\r\n",
        "        \"clip_norm\": 2,\r\n",
        "        \"dropout_rate\": 0.4,\r\n",
        "        \"l2_reg_coef\": 0.0003,\r\n",
        "        \"hidden_size\": 128,\r\n",
        "        \"dense_size\": 160,\r\n",
        "        \"word_vocab\": \"#word_vocab\",\r\n",
        "        \"database\": null,\r\n",
        "        \"nlg_manager\": {\r\n",
        "          \"class_name\": \"gobot_json_nlg_manager\",\r\n",
        "          \"data_path\": \"{DATA_PATH}\",\r\n",
        "          \"dataset_reader_class\": \"md_yaml_dialogs_reader\",\r\n",
        "          \"actions2slots_path\": \"{DATA_PATH}/dstc2-actions2slots.json\",\r\n",
        "          \"api_call_action\": null\r\n",
        "        },\r\n",
        "        \"api_call_action\": null,\r\n",
        "        \"use_action_mask\": false,\r\n",
        "        \"slot_filler\": {\r\n",
        "          \"config_path\": \"dp_minimal_demo_dir/slotfill_config.json\"\r\n",
        "        },\r\n",
        "        \"intent_classifier\": null,\r\n",
        "        \"embedder\": null,\r\n",
        "        \"bow_embedder\": null,\r\n",
        "        \"tokenizer\": {\r\n",
        "          \"class_name\": \"split_tokenizer\"\r\n",
        "        },\r\n",
        "        \"tracker\": {\r\n",
        "          \"class_name\": \"featurized_tracker\",\r\n",
        "          \"slot_names\": [\r\n",
        "            \"animal\", \"time\"\r\n",
        "          ]\r\n",
        "        }\r\n",
        "      }\r\n",
        "    ]\r\n",
        "  },\r\n",
        "  \"train\": {\r\n",
        "    \"epochs\": 200,\r\n",
        "    \"batch_size\": 4,\r\n",
        "    \"metrics\": [\r\n",
        "      \"per_item_action_accuracy\"\r\n",
        "    ],\r\n",
        "    \"validation_patience\": 10,\r\n",
        "    \"val_every_n_batches\": 15,\r\n",
        "    \"log_every_n_batches\": 15,\r\n",
        "    \"log_on_k_batches\": -1,\r\n",
        "    \"show_examples\": false,\r\n",
        "    \"evaluation_targets\": [\r\n",
        "      \"valid\",\r\n",
        "      \"test\"\r\n",
        "    ],\r\n",
        "    \"class_name\": \"nn_trainer\"\r\n",
        "  },\r\n",
        "  \"metadata\": {\r\n",
        "    \"variables\": {\r\n",
        "      \"ROOT_PATH\": \"~/.deeppavlov\",\r\n",
        "      \"CONFIGS_PATH\": \"{DEEPPAVLOV_PATH}/configs\",\r\n",
        "      \"DOWNLOADS_PATH\": \"{ROOT_PATH}/downloads\",\r\n",
        "      \"DATA_PATH\": \"dp_minimal_demo_dir\",\r\n",
        "      \"MODELS_PATH\": \"{ROOT_PATH}/models\",\r\n",
        "      \"MODEL_PATH\": \"dp_minimal_demo_dir\"\r\n",
        "    },\r\n",
        "    \"requirements\": [\r\n",
        "      \"{DEEPPAVLOV_PATH}/requirements/tf.txt\",\r\n",
        "      \"{DEEPPAVLOV_PATH}/requirements/gensim.txt\",\r\n",
        "      \"{DEEPPAVLOV_PATH}/requirements/spacy.txt\",\r\n",
        "      \"{DEEPPAVLOV_PATH}/requirements/en_core_web_sm.txt\"\r\n",
        "    ],\r\n",
        "    \"download\": []\r\n",
        "  }\r\n",
        "}"
      ],
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Writing dp_minimal_demo_dir/gobot_config.json\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "7JuDe7fkK_B6",
        "outputId": "499b13d9-10dd-499c-9d56-7220cb247a98"
      },
      "source": [
        "!python -m deeppavlov install {GOBOT_CONFIG_PATH}"
      ],
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Collecting gensim==3.8.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/d1/dd/112bd4258cee11e0baaaba064060eb156475a42362e59e3ff28e7ca2d29d/gensim-3.8.1-cp36-cp36m-manylinux1_x86_64.whl (24.2MB)\n",
            "\u001b[K     |████████████████████████████████| 24.2MB 5.9MB/s \n",
            "\u001b[?25hRequirement already satisfied: smart-open>=1.8.1 in /usr/local/lib/python3.6/dist-packages (from gensim==3.8.1) (4.0.1)\n",
            "Requirement already satisfied: scipy>=0.18.1 in /usr/local/lib/python3.6/dist-packages (from gensim==3.8.1) (1.4.1)\n",
            "Requirement already satisfied: numpy>=1.11.3 in /usr/local/lib/python3.6/dist-packages (from gensim==3.8.1) (1.18.0)\n",
            "Requirement already satisfied: six>=1.5.0 in /usr/local/lib/python3.6/dist-packages (from gensim==3.8.1) (1.15.0)\n",
            "Installing collected packages: gensim\n",
            "  Found existing installation: gensim 3.6.0\n",
            "    Uninstalling gensim-3.6.0:\n",
            "      Successfully uninstalled gensim-3.6.0\n",
            "Successfully installed gensim-3.8.1\n",
            "Requirement already satisfied: en_core_web_sm==2.2.5 from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.5/en_core_web_sm-2.2.5.tar.gz#egg=en_core_web_sm==2.2.5 in /usr/local/lib/python3.6/dist-packages (2.2.5)\n",
            "Requirement already satisfied: spacy>=2.2.2 in /usr/local/lib/python3.6/dist-packages (from en_core_web_sm==2.2.5) (2.2.4)\n",
            "Requirement already satisfied: plac<1.2.0,>=0.9.6 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (1.1.3)\n",
            "Requirement already satisfied: thinc==7.4.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (7.4.0)\n",
            "Requirement already satisfied: blis<0.5.0,>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (0.4.1)\n",
            "Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (1.0.5)\n",
            "Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (1.0.0)\n",
            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (3.0.5)\n",
            "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (4.41.1)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (50.3.2)\n",
            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (2.0.5)\n",
            "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (1.0.5)\n",
            "Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (0.8.0)\n",
            "Requirement already satisfied: numpy>=1.15.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (1.18.0)\n",
            "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/local/lib/python3.6/dist-packages (from spacy>=2.2.2->en_core_web_sm==2.2.5) (2.22.0)\n",
            "Requirement already satisfied: importlib-metadata>=0.20; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_sm==2.2.5) (3.3.0)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_sm==2.2.5) (1.24.3)\n",
            "Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_sm==2.2.5) (2.8)\n",
            "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_sm==2.2.5) (3.0.4)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy>=2.2.2->en_core_web_sm==2.2.5) (2020.12.5)\n",
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=0.20; python_version < \"3.8\"->catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_sm==2.2.5) (3.4.0)\n",
            "Requirement already satisfied: typing-extensions>=3.6.4; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=0.20; python_version < \"3.8\"->catalogue<1.1.0,>=0.0.7->spacy>=2.2.2->en_core_web_sm==2.2.5) (3.7.4.3)\n",
            "Collecting tensorflow==1.15.2\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/9a/d9/fd234c7bf68638423fb8e7f44af7fcfce3bcaf416b51e6d902391e47ec43/tensorflow-1.15.2-cp36-cp36m-manylinux2010_x86_64.whl (110.5MB)\n",
            "\u001b[K     |████████████████████████████████| 110.5MB 80kB/s \n",
            "\u001b[?25hRequirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (1.1.0)\n",
            "Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (3.3.0)\n",
            "Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (1.15.0)\n",
            "Requirement already satisfied: wrapt>=1.11.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (1.12.1)\n",
            "Requirement already satisfied: numpy<2.0,>=1.16.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (1.18.0)\n",
            "Requirement already satisfied: wheel>=0.26; python_version >= \"3\" in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (0.36.2)\n",
            "Requirement already satisfied: grpcio>=1.8.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (1.32.0)\n",
            "Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (3.12.4)\n",
            "Collecting tensorflow-estimator==1.15.1\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/de/62/2ee9cd74c9fa2fa450877847ba560b260f5d0fb70ee0595203082dafcc9d/tensorflow_estimator-1.15.1-py2.py3-none-any.whl (503kB)\n",
            "\u001b[K     |████████████████████████████████| 512kB 36.6MB/s \n",
            "\u001b[?25hRequirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (1.1.2)\n",
            "Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (0.10.0)\n",
            "Requirement already satisfied: astor>=0.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (0.8.1)\n",
            "Collecting gast==0.2.2\n",
            "  Downloading https://files.pythonhosted.org/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz\n",
            "Collecting keras-applications>=1.0.8\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl (50kB)\n",
            "\u001b[K     |████████████████████████████████| 51kB 5.7MB/s \n",
            "\u001b[?25hCollecting tensorboard<1.16.0,>=1.15.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/1e/e9/d3d747a97f7188f48aa5eda486907f3b345cd409f0a0850468ba867db246/tensorboard-1.15.0-py3-none-any.whl (3.8MB)\n",
            "\u001b[K     |████████████████████████████████| 3.8MB 28.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: google-pasta>=0.1.6 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.15.2) (0.2.0)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from protobuf>=3.6.1->tensorflow==1.15.2) (50.3.2)\n",
            "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras-applications>=1.0.8->tensorflow==1.15.2) (2.10.0)\n",
            "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (1.0.1)\n",
            "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (3.3.3)\n",
            "Requirement already satisfied: importlib-metadata; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (3.3.0)\n",
            "Requirement already satisfied: typing-extensions>=3.6.4; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version < \"3.8\"->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (3.7.4.3)\n",
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata; python_version < \"3.8\"->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.2) (3.4.0)\n",
            "Building wheels for collected packages: gast\n",
            "  Building wheel for gast (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
            "  Created wheel for gast: filename=gast-0.2.2-cp36-none-any.whl size=7540 sha256=df64dbcaf33b275d067ca0ed9d534fa0e806076dc7a1ec5314b65e337463989c\n",
            "  Stored in directory: /root/.cache/pip/wheels/5c/2e/7e/a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd\n",
            "Successfully built gast\n",
            "\u001b[31mERROR: tensorflow-probability 0.11.0 has requirement gast>=0.3.2, but you'll have gast 0.2.2 which is incompatible.\u001b[0m\n",
            "Installing collected packages: tensorflow-estimator, gast, keras-applications, tensorboard, tensorflow\n",
            "  Found existing installation: tensorflow-estimator 2.4.0\n",
            "    Uninstalling tensorflow-estimator-2.4.0:\n",
            "      Successfully uninstalled tensorflow-estimator-2.4.0\n",
            "  Found existing installation: gast 0.3.3\n",
            "    Uninstalling gast-0.3.3:\n",
            "      Successfully uninstalled gast-0.3.3\n",
            "  Found existing installation: tensorboard 2.4.0\n",
            "    Uninstalling tensorboard-2.4.0:\n",
            "      Successfully uninstalled tensorboard-2.4.0\n",
            "  Found existing installation: tensorflow 2.4.0\n",
            "    Uninstalling tensorflow-2.4.0:\n",
            "      Successfully uninstalled tensorflow-2.4.0\n",
            "Successfully installed gast-0.2.2 keras-applications-1.0.8 tensorboard-1.15.0 tensorflow-1.15.2 tensorflow-estimator-1.15.1\n",
            "Collecting spacy==2.2.3\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/47/13/80ad28ef7a16e2a86d16d73e28588be5f1085afd3e85e4b9b912bd700e8a/spacy-2.2.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)\n",
            "\u001b[K     |████████████████████████████████| 10.4MB 5.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: plac<1.2.0,>=0.9.6 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (1.1.3)\n",
            "Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (0.8.0)\n",
            "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (1.0.5)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (50.3.2)\n",
            "Requirement already satisfied: srsly<1.1.0,>=0.1.0 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (1.0.5)\n",
            "Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (1.0.0)\n",
            "Requirement already satisfied: blis<0.5.0,>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (0.4.1)\n",
            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (3.0.5)\n",
            "Requirement already satisfied: numpy>=1.15.0 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (1.18.0)\n",
            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (2.0.5)\n",
            "Collecting thinc<7.4.0,>=7.3.0\n",
            "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/07/59/6bb553bc9a5f072d3cd479fc939fea0f6f682892f1f5cff98de5c9b615bb/thinc-7.3.1-cp36-cp36m-manylinux1_x86_64.whl (2.2MB)\n",
            "\u001b[K     |████████████████████████████████| 2.2MB 54.4MB/s \n",
            "\u001b[?25hRequirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/local/lib/python3.6/dist-packages (from spacy==2.2.3) (2.22.0)\n",
            "Requirement already satisfied: importlib-metadata>=0.20; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from catalogue<1.1.0,>=0.0.7->spacy==2.2.3) (3.3.0)\n",
            "Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in /usr/local/lib/python3.6/dist-packages (from thinc<7.4.0,>=7.3.0->spacy==2.2.3) (4.41.1)\n",
            "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy==2.2.3) (1.24.3)\n",
            "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy==2.2.3) (3.0.4)\n",
            "Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy==2.2.3) (2.8)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests<3.0.0,>=2.13.0->spacy==2.2.3) (2020.12.5)\n",
            "Requirement already satisfied: typing-extensions>=3.6.4; python_version < \"3.8\" in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=0.20; python_version < \"3.8\"->catalogue<1.1.0,>=0.0.7->spacy==2.2.3) (3.7.4.3)\n",
            "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata>=0.20; python_version < \"3.8\"->catalogue<1.1.0,>=0.0.7->spacy==2.2.3) (3.4.0)\n",
            "Installing collected packages: thinc, spacy\n",
            "  Found existing installation: thinc 7.4.0\n",
            "    Uninstalling thinc-7.4.0:\n",
            "      Successfully uninstalled thinc-7.4.0\n",
            "  Found existing installation: spacy 2.2.4\n",
            "    Uninstalling spacy-2.2.4:\n",
            "      Successfully uninstalled spacy-2.2.4\n",
            "Successfully installed spacy-2.2.3 thinc-7.3.1\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_x8R0PbIHPS8",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "aa690f66-fef9-4e3c-d7d7-eb72b140dc8f"
      },
      "source": [
        "gobot_config = read_json(GOBOT_CONFIG_PATH)\n",
        "\n",
        "gobot_config[\"chainer\"][\"pipe\"][-1][\"tracker\"][\"domain_yml_path\"] = DOMAIN_PATH\n",
        "gobot_config[\"chainer\"][\"pipe\"][-1][\"tracker\"][\"stories_yml_path\"] = STORIES_PATH\n",
        "gobot_config['chainer']['pipe'][-1]['slot_filler'] = {'config_path': SLOTFILL_CONFIG_PATH}\n",
        "\n",
        "json.dump(gobot_config, open('gobot_config.json', 'wt'))\n",
        "\n",
        "bot = train_model(gobot_config, download=False)"
      ],
      "execution_count": 18,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:12.690 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpv8sued_o]\n",
            "2020-12-21 09:08:12.696 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpuqnpqbo6]\n",
            "2020-12-21 09:08:12.701 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpkb9v7x1e]\n",
            "2020-12-21 09:08:12.716 INFO in 'deeppavlov.core.data.simple_vocab'['simple_vocab'] at line 101: [saving vocabulary to /content/dp_minimal_demo_dir/word.dict]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:37: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:222: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:222: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:14.836 INFO in 'deeppavlov.models.go_bot.nlg.nlg_manager'['mock_json_nlg_manager'] at line 94: INSIDE MockJSONNLGManager _load_actions2slots_mapping(): actions2slots_json_path=/content/dp_minimal_demo_dir/dstc2-actions2slots.json DOES NOT EXIST. initialized actions2slots mapping with an empty one: {}\n",
            "2020-12-21 09:08:14.849 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpaet6g6sn]\n",
            "2020-12-21 09:08:14.861 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpgkp2m65m]\n",
            "2020-12-21 09:08:14.876 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmp52shz7ii]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "zoo_form\n",
            "zoo_form\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/common/registry.py:40: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:194: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:250: The name tf.placeholder_with_default is deprecated. Please use tf.compat.v1.placeholder_with_default instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:265: The name tf.nn.rnn_cell.LSTMStateTuple is deprecated. Please use tf.compat.v1.nn.rnn_cell.LSTMStateTuple instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:276: dense (from tensorflow.python.layers.core) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Use keras.layers.Dense instead.\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/layers/core.py:187: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Please use `layer.__call__` method instead.\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:285: LSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:292: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Please use `keras.layers.RNN(cell)`, which is equivalent to this API\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/rnn_cell_impl.py:958: Layer.add_variable (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Please use `layer.add_weight` method instead.\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/rnn_cell_impl.py:962: calling Zeros.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Call initializer instance with the dtype argument instead of passing it to the constructor\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/rnn.py:244: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Use tf.where in 2.0, which has the same broadcast rule as np.where\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:246: The name tf.losses.get_regularization_loss is deprecated. Please use tf.compat.v1.losses.get_regularization_loss instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:122: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:127: The name tf.get_collection is deprecated. Please use tf.compat.v1.get_collection instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:127: The name tf.GraphKeys is deprecated. Please use tf.compat.v1.GraphKeys instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/variables.py:2825: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:79: The name tf.global_variables_initializer is deprecated. Please use tf.compat.v1.global_variables_initializer instead.\n",
            "\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/models/go_bot/policy/policy_network.py:335: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.\n",
            "Instructions for updating:\n",
            "Use standard file APIs to check for files with this prefix.\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:15.779 INFO in 'deeppavlov.models.go_bot.policy.policy_network'['policy_network'] at line 89: INSIDE PolicyNetwork init(). Initializing PolicyNetwork from scratch.\n",
            "2020-12-21 09:08:16.5 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 199: Initial best per_item_action_accuracy of 0.4\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.4}, \"time_spent\": \"0:00:01\", \"epochs_done\": 0, \"batches_seen\": 0, \"train_examples_seen\": 0, \"impatience\": 0, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:16.893 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 207: Improved best per_item_action_accuracy of 0.875\n",
            "2020-12-21 09:08:16.894 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 209: Saving model\n",
            "2020-12-21 09:08:16.896 INFO in 'deeppavlov.core.models.tf_model'['tf_model'] at line 75: [saving model to /content/dp_minimal_demo_dir/model/policy]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:01\", \"epochs_done\": 2, \"batches_seen\": 15, \"train_examples_seen\": 60, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.8913657089074453}}\n",
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/deeppavlov/core/models/tf_model.py:77: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.\n",
            "\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:02\", \"epochs_done\": 2, \"batches_seen\": 15, \"train_examples_seen\": 60, \"impatience\": 0, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:17.591 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:02\", \"epochs_done\": 4, \"batches_seen\": 30, \"train_examples_seen\": 120, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.2988798429568609}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:02\", \"epochs_done\": 4, \"batches_seen\": 30, \"train_examples_seen\": 120, \"impatience\": 1, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:18.155 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:03\", \"epochs_done\": 7, \"batches_seen\": 45, \"train_examples_seen\": 180, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.17737904439369837}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:03\", \"epochs_done\": 7, \"batches_seen\": 45, \"train_examples_seen\": 180, \"impatience\": 2, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:18.703 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:03\", \"epochs_done\": 9, \"batches_seen\": 60, \"train_examples_seen\": 240, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.1792086939016978}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:03\", \"epochs_done\": 9, \"batches_seen\": 60, \"train_examples_seen\": 240, \"impatience\": 3, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:19.285 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:04\", \"epochs_done\": 12, \"batches_seen\": 75, \"train_examples_seen\": 300, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.19470323820908864}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:04\", \"epochs_done\": 12, \"batches_seen\": 75, \"train_examples_seen\": 300, \"impatience\": 4, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:19.887 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:04\", \"epochs_done\": 14, \"batches_seen\": 90, \"train_examples_seen\": 360, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.17502874781688055}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:05\", \"epochs_done\": 14, \"batches_seen\": 90, \"train_examples_seen\": 360, \"impatience\": 5, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:20.502 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:05\", \"epochs_done\": 17, \"batches_seen\": 105, \"train_examples_seen\": 420, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.17020882417758307}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:05\", \"epochs_done\": 17, \"batches_seen\": 105, \"train_examples_seen\": 420, \"impatience\": 6, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:21.107 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:06\", \"epochs_done\": 19, \"batches_seen\": 120, \"train_examples_seen\": 480, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.16489881575107573}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:06\", \"epochs_done\": 19, \"batches_seen\": 120, \"train_examples_seen\": 480, \"impatience\": 7, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:21.695 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:06\", \"epochs_done\": 22, \"batches_seen\": 135, \"train_examples_seen\": 540, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.17317733069260915}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:06\", \"epochs_done\": 22, \"batches_seen\": 135, \"train_examples_seen\": 540, \"impatience\": 8, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:22.267 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:07\", \"epochs_done\": 24, \"batches_seen\": 150, \"train_examples_seen\": 600, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.16087978482246398}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:07\", \"epochs_done\": 24, \"batches_seen\": 150, \"train_examples_seen\": 600, \"impatience\": 9, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:22.822 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 212: Did not improve on the per_item_action_accuracy of 0.875\n",
            "2020-12-21 09:08:22.826 INFO in 'deeppavlov.core.trainers.nn_trainer'['nn_trainer'] at line 308: Ran out of patience\n",
            "2020-12-21 09:08:22.839 INFO in 'deeppavlov.core.data.simple_vocab'['simple_vocab'] at line 115: [loading vocabulary from /content/dp_minimal_demo_dir/word.dict]\n",
            "2020-12-21 09:08:22.841 INFO in 'deeppavlov.models.go_bot.nlg.nlg_manager'['mock_json_nlg_manager'] at line 94: INSIDE MockJSONNLGManager _load_actions2slots_mapping(): actions2slots_json_path=/content/dp_minimal_demo_dir/dstc2-actions2slots.json DOES NOT EXIST. initialized actions2slots mapping with an empty one: {}\n",
            "2020-12-21 09:08:22.852 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpnlcs5z75]\n",
            "2020-12-21 09:08:22.864 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpa52useo9]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"train\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:07\", \"epochs_done\": 27, \"batches_seen\": 165, \"train_examples_seen\": 660, \"learning_rate\": 0.003, \"momentum\": 0.95, \"loss\": 0.17012472152709962}}\n",
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:08\", \"epochs_done\": 27, \"batches_seen\": 165, \"train_examples_seen\": 660, \"impatience\": 10, \"patience_limit\": 10}}\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:22.877 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpsntfmuum]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "zoo_form\n",
            "zoo_form\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:23.804 INFO in 'deeppavlov.models.go_bot.policy.policy_network'['policy_network'] at line 86: INSIDE PolicyNetwork init(). Initializing PolicyNetwork from checkpoint.\n",
            "2020-12-21 09:08:23.810 INFO in 'deeppavlov.core.models.tf_model'['tf_model'] at line 51: [loading model from /content/dp_minimal_demo_dir/model/policy]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "INFO:tensorflow:Restoring parameters from /content/dp_minimal_demo_dir/model/policy\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:24.256 INFO in 'deeppavlov.core.data.simple_vocab'['simple_vocab'] at line 115: [loading vocabulary from /content/dp_minimal_demo_dir/word.dict]\n",
            "2020-12-21 09:08:24.259 INFO in 'deeppavlov.models.go_bot.nlg.nlg_manager'['mock_json_nlg_manager'] at line 94: INSIDE MockJSONNLGManager _load_actions2slots_mapping(): actions2slots_json_path=/content/dp_minimal_demo_dir/dstc2-actions2slots.json DOES NOT EXIST. initialized actions2slots mapping with an empty one: {}\n",
            "2020-12-21 09:08:24.270 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpb7o0j9sp]\n",
            "2020-12-21 09:08:24.284 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpswq7zy_3]\n",
            "2020-12-21 09:08:24.296 INFO in 'deeppavlov.dataset_readers.dstc2_reader'['dstc2_reader'] at line 112: [loading dialogs from /tmp/tmpmf001tva]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "{\"valid\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:01\"}}\n",
            "{\"test\": {\"eval_examples_count\": 24, \"metrics\": {\"per_item_action_accuracy\": 0.875}, \"time_spent\": \"0:00:01\"}}\n",
            "zoo_form\n",
            "zoo_form\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "2020-12-21 09:08:25.117 INFO in 'deeppavlov.models.go_bot.policy.policy_network'['policy_network'] at line 86: INSIDE PolicyNetwork init(). Initializing PolicyNetwork from checkpoint.\n",
            "2020-12-21 09:08:25.124 INFO in 'deeppavlov.core.models.tf_model'['tf_model'] at line 51: [loading model from /content/dp_minimal_demo_dir/model/policy]\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "stream",
          "text": [
            "INFO:tensorflow:Restoring parameters from /content/dp_minimal_demo_dir/model/policy\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uWhEjOALPW9O"
      },
      "source": [
        "### interact with the bot"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "k6t9U-aSg1V1"
      },
      "source": [
        "Let's interact with the bot to see if it performs formfilling properly"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "zr7F0miHt6Ex",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "dc2f6011-9081-42db-c342-62ec53ce4070"
      },
      "source": [
        "replices = [\n",
        "    \"start\",\n",
        "    \"hi bot! i'd like to go to the zoo\",\n",
        "    \"i'd love to see a wild cat\",\n",
        "    \"evenin would be great!\"\n",
        "]\n",
        "bot.reset()\n",
        "for rep in replices:\n",
        "    res_bot = bot([rep])[0][0].to_serializable_dict()\n",
        "    print(str(res_bot))"
      ],
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "zoo_form\n",
            "{'start': {}}\n",
            "{'utter_ask_animal': {}}\n",
            "{'utter_ask_time': {}}\n",
            "{'utter_api_call': {}}\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}
